let vm = new Vue({
    el: '#app',
    data: {
        taskName: '',
        tasklist: [
            
        ]
    },
    methods: {
        addTask() {
            var obj = {
                id: this.tasklist.length + 1,
                name: this.taskName, status: false
            };
            this.tasklist.push(obj);
            this.taskName = '';
        },
        delTask(index) {
            this.tasklist.splice(index, 1);
            this.update();
        },
        update() {
            for (let i = 0; i < this.tasklist.length; i++){
                for (let index in this.tasklist[i]) {
                    this.tasklist[i].id = i + 1;
                }
            }  
        },
        changeStatus(item) {
            item.status = !item.status;
        }
    },
    computed: {
        unFinishCount() {
            let arr = this.tasklist.filter((item) => {
                return item.status == false;
            })
            return arr.length;
       }
    },
})